const {
	Controller
} = require('uni-cloud-router')

module.exports = class UserController extends Controller {
	// const { ctx, service } = this // 可以从实例中获取上下文和sevice
	async addUser() {
		const {
			username,
			password,
			role,
			mobile,
			email,
			status,
			type,
			specialty,
			school
		} = this.ctx.data
		// 添加用户
		const result = await this.ctx.uniID.register({
			username,
			password,
			role,
			mobile,
			email,
			type,
			specialty,
			school,
			status
		})
		delete result.token
		delete result.tokenExpired
		return result
	}

	async resetPwd() {
		const {
			uid,
			password
		} = this.ctx.data
	
		const result = await this.ctx.uniID.resetPwd({
			uid,
			password
		})

		return result
	}
}
